<script>
import config from '../config'

export default {
  name: 'NewsItem',
  data() {
    return {
      cdn: config.cdn
    }
  },
  props: {
    news: {
      type: Object,
      default: {}
    }
  }
}
</script>

<template>
<li class="item news-item">
  <a :href="news.link" target="_blank" class="news-image" >
    <img :src="`${cdn}/${news.cover}-0.6`" >
  </a>
  <div class="content">
    <label v-if="news.hot">NEW</label>
    <h2 class="news-title"><a :href="news.link" target="_blank">{{ news.name }}</a></h2>
    <p>{{ news.summary }}</p>
    <p style="margin-top: 5px;"><small>{{ news.createTime }}</small></p>
  </div>
</li>
</template>

<style>
.news-item {
  position: relative;
  border: 0px;
  border-bottom: 2px solid #F1F1F1;
  margin: 0px;
  padding: 20px 0;
}

.news-item .news-image {
  float: left;
  max-width: 256px;
  max-height: 150px;
}

.news-item .news-image > img {
  display: block;
  width: 100%;
  min-height: 100%;
}

.news-item label {
  position : relative;  
  display: block;
  width: 60px;
  height: 17px;
  font-size: 12px;
  font-weight: bold;
  background-color: #FBD700;
  padding: 1px 12px 0 0;
  text-align: center;
}

.news-item label:after {
  position: absolute;
  content: '';
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-right: 8px solid #fff;
  top: 0px;
  right: 0px; 
}

.news-item .content {
  position: relative;
  padding-left: 273px;
}

.news-item .news-title {
  font-size: 20px;
  margin: 0;
}

.news-item .news-title > a {
  display: block;
  color: inherit;
  text-decoration: none;
}
</style>
